def isPrime(x):
    for y in range(2, int(x**0.5)+1):
        if x%y==0:
            return 0
        return 1
s=input().split()
z=['zero' , 'one' ,'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
rez=0
d=100
for x in s:
    for i in range(len(z)):
        if x==z[i]:
            rez +=i*d
            d=d/100
            break
print(rez)
if len(s)==3:
    flag= True 
else:
    flag= False
delta = 1
while flag:
    if isPrime(rez - delta):
        print (rez - delta)
        break
    if isPrime(rez+delta):
        print(rez+delta)
if flag == False:
    print("Wrong input")